<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var minimumTime = function (a, b) {
      // 二分法
      let l = 1, r = Math.min(...a) * b;
      while (l < r) {
        // const mid = (l + r) >> 1; 
        let mid = Math.floor((r - l) / 2) + l;
        let count = 0;
        for (let i = 0; i < a.length; i++) {
          count += Math.floor(mid / a[i]);
        }
        if (count >= b) {
          r = mid;
        } else {
          l = mid + 1;
        }
      }

      return l;

    };
    console.log(minimumTime(a = [1, 2, 3], b = 5));


  </script>
</body>

</html>